﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Terraria.Localization;

namespace Terraria.ModLoader.Default.Patreon
{
	// Token: 0x02000311 RID: 785
	internal abstract class PatreonItem : ModItem
	{
		// Token: 0x17000200 RID: 512
		// (get) Token: 0x06001DA5 RID: 7589
		public abstract string PatreonName { get; }

		// Token: 0x17000201 RID: 513
		// (get) Token: 0x06001DA6 RID: 7590
		public abstract PatreonItem.PatreonItemType PatreonEquipType { get; }

		// Token: 0x06001DA7 RID: 7591 RVA: 0x00439604 File Offset: 0x00437804
		private string GetEquipTypeSuffix()
		{
			switch (this.PatreonEquipType)
			{
			case PatreonItem.PatreonItemType.Head:
				return "Head";
			case PatreonItem.PatreonItemType.Body:
				return "Body";
			case PatreonItem.PatreonItemType.Legs:
				return "Legs";
			case PatreonItem.PatreonItemType.Wings:
				return "Wings";
			default:
				return "Unknown";
			}
		}

		// Token: 0x17000202 RID: 514
		// (get) Token: 0x06001DA8 RID: 7592 RVA: 0x00015077 File Offset: 0x00013277
		public override string Texture
		{
			get
			{
				return string.Format("ModLoader/Patreon.{0}_{1}", this.PatreonName, this.GetEquipTypeSuffix());
			}
		}

		// Token: 0x06001DA9 RID: 7593 RVA: 0x0001508F File Offset: 0x0001328F
		public override void SetStaticDefaults()
		{
			base.DisplayName.SetDefault(string.Format("{0}'s {1}", this.PatreonName, this.GetEquipTypeSuffix()));
		}

		// Token: 0x06001DAA RID: 7594 RVA: 0x000150B2 File Offset: 0x000132B2
		public override void SetDefaults()
		{
			base.item.rare = 9;
			base.item.vanity = true;
		}

		// Token: 0x06001DAB RID: 7595 RVA: 0x00439650 File Offset: 0x00437850
		public override void ModifyTooltips(List<TooltipLine> tooltips)
		{
			tooltips.Add(new TooltipLine(base.mod, "PatreonThanks", Language.GetTextValue("tModLoader.PatreonSetTooltip"))
			{
				overrideColor = new Color?(Color.Aquamarine)
			});
		}

		// Token: 0x06001DAC RID: 7596 RVA: 0x00439690 File Offset: 0x00437890
		internal static bool TryGettingPatreonArmor(Player player)
		{
			if (Main.rand.NextBool(20))
			{
				Mod mod = ModLoader.GetMod("ModLoader");
				switch (Main.rand.Next(4))
				{
				case 0:
					player.QuickSpawnItem(mod.ItemType<toplayz_Head>(), 1);
					player.QuickSpawnItem(mod.ItemType<toplayz_Body>(), 1);
					player.QuickSpawnItem(mod.ItemType<toplayz_Legs>(), 1);
					return true;
				case 1:
					player.QuickSpawnItem(mod.ItemType<PotyBlank_Head>(), 1);
					player.QuickSpawnItem(mod.ItemType<PotyBlank_Body>(), 1);
					player.QuickSpawnItem(mod.ItemType<PotyBlank_Legs>(), 1);
					return true;
				case 2:
					player.QuickSpawnItem(mod.ItemType<KittyKitCatCat_Head>(), 1);
					player.QuickSpawnItem(mod.ItemType<KittyKitCatCat_Body>(), 1);
					player.QuickSpawnItem(mod.ItemType<KittyKitCatCat_Legs>(), 1);
					return true;
				case 3:
					player.QuickSpawnItem(mod.ItemType<Dinidini_Head>(), 1);
					player.QuickSpawnItem(mod.ItemType<Dinidini_Body>(), 1);
					player.QuickSpawnItem(mod.ItemType<Dinidini_Legs>(), 1);
					player.QuickSpawnItem(mod.ItemType<Dinidini_Wings>(), 1);
					return true;
				}
			}
			return false;
		}

		// Token: 0x02000312 RID: 786
		public enum PatreonItemType
		{
			// Token: 0x04001904 RID: 6404
			Head,
			// Token: 0x04001905 RID: 6405
			Body,
			// Token: 0x04001906 RID: 6406
			Legs,
			// Token: 0x04001907 RID: 6407
			Wings
		}
	}
}
